import axios from "axios";
//获取不同环境的参数
// import { baseURL } from '@/config/index.js';
// console.log(baseURL);

// create an axios instance
const service = axios.create({
    baseURL: "", // url = base url + request url
    // withCredentials: true, // send cookies when cross-domain requests
    timeout: 5000, // request timeout
});

// 请求拦截器 request interceptor
// service.interceptors.request.use(
//     config => {
//     // do something before request is sent

//     },
// );

// 响应拦截器 response interceptor
// service.interceptors.response.use(

// );

class eFlyNetWork{
    //统一post请求接口
    post(url, parameter){
        return new Promise((resolve, reject) => {
            service.post(url, parameter)
                .then(res => {
                    resolve(res);
                })
                .catch(err => {
                    reject(err)
                })
        })
    }
    //统一get请求接口
    get(url, parameter){
        return new Promise((resolve, reject) => {
            service.get(url, parameter)
                .then(res => {
                    resolve(res.data);
                })
                .catch(err => {
                    reject(err)
                })
        })
    }
    //统一上传文件接口
    uploadFile(){

    }
}
//export default service;
export default new eFlyNetWork();
